
<nav class="navbar navbar-default">
  <div class="container">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="<%= root_path %>">阳毅商城</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="<%= root_path %>">首页 <span class="sr-only">(current_user.name)</span></a></li>
      </ul>
      <%= form_tag root_path, method: :get, class: "navbar-form navbar-left" do %>
        <div class="form-group">
          <% if @category %>
            <input type="hidden" name="category_id" value="<%= @category.id %>" />
          <% end %>
          <div id="autocomplete">
            <autocomplete-input :options="options" @select="onOptionSelect">
              <template slot="item" scope="option">
                <article class="media">
                  <figure class="media-left">
                    <p class="image is-64x64">
                      <img :src="option.thumbnail">
                    </p>
                  </figure>
                  <p>
                    <strong>{{ option.title }}</strong>
                    <br> {{ option.description }}
                  </p>
                </article>
              </template>
            </autocomplete-input>
          </div>
        </div>
        <button type="submit" class="btn btn-default">搜索</button>
      <% end %>
      <ul class="nav navbar-nav navbar-right">
        <li><%= link_to "购物车(#{@cart_count})", carts_path, "data-jq-dropdown": "#jq-dropdown-2"  %></li>
        <% unless logined? %>
          <li><a href="<%= new_user_path %>">注册</a></li>
          <li><a href="<%= new_session_path %>">登录</a></li>
        <% else %>
          <li><a href="#">欢迎你, <%= current_user.name %></a></li>
          <li class="dropdown">
            <a href="#" data-jq-dropdown="#jq-dropdown-1">个人中心 <span class="caret"></span></a>
          </li>
        <% end -%>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

